package com.sjm.bookshop.service.slide;

import com.sjm.bookshop.dao.SlideDao;
import com.sjm.bookshop.entity.Slide;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SlideService {
    @Autowired
    private SlideDao slideDao;

    //查询所有
    public List<Slide> slideList() {
        return slideDao.selectSlideList();
    }

    //    修改状态
    public int changeStatus(int slideId, int slidestatus) {
        return slideDao.changeSlideStatus(slideId, slidestatus);
    }

    //    模糊查询
    public List<Slide> slideListByLike(String keyWord) {
        return slideDao.selectByLike(keyWord);
    }

    //删除
    public int delete(int slideId) {
        return slideDao.deleteSlide(slideId);
    }

    //    添加轮播
    public int addOneSlide(Slide slide) {
        slide.setSlidestatus(1);
        slide.setAddtime(new Date());
        return slideDao.addSlide(slide);
    }

    //    修改轮播
    public int UpdateOneSlide(Slide slide) {
        slide.setUpdatetime(new Date());
        return slideDao.UpdateSlide(slide);
    }
}
